﻿/**
 * @author alex
 */
Namespace("sketch.framework");
(function () {
    var fwk = sketch.framework;
    fwk.Font = klass(fwk.ContextModifier, {
        _constructor:function(values) {
            this._data = {
                size:"28",
                lineHeight:"30",
                style: "normal",
                varian: "normal",
                family: "Times New Roman",
                weight:"normal"
            };

            this.createProperty("size", "Size", 10).editorTemplate("#editor-dropdown")
                    .possibleValues({"10": "10 pt", "12": "12 pt", "28": "28 pt", "42": "42 pt"})
                    .useInModel();

            this.createProperty("family", "Family", "Arial").editorTemplate("#editor-dropdown")
                    .possibleValues({"Helvetica Neue": "Helvetica Neue", "Times New Roman": "Times New Roman", "Arial": "Arial"})
                    .useInModel();

            this.createProperty("bold", "Bold", false).useInModel()
                    .editorTemplate("#editor-pushbutton", {
                        "true": "/img/properties/font/bold-yes.png",
                        "false": "/img/properties/font/bold-no.png"
                    });

            this.createProperty("italic", "Italic", false).useInModel()
                    .editorTemplate("#editor-pushbutton", {
                        "true": "/img/properties/font/italic-yes.png",
                        "false": "/img/properties/font/italic-no.png"
                    });

            this.createProperty("color", "Color", "#000000").editorTemplate("#editor-dropdown")
                    .possibleValues({"#FFFFFF": "White", "#000000": "Black"})
                    .useInModel();

            this.init(values);
        },
        cssString:function() {
            var res = [
                this.get("bold") ? "Bold" : "",
                this.get("italic") ? "Italic" : "",
                this._data.weight,
                this.get("size") + "pt/" + this._data.lineHeight + "px",
                '"' + this.get("family") + '"'

            ].join(' ');

            return res;
        },
        size:function(value) {
            return this.properties.size(value);
        },
        style:function(value) {
            if (arguments.length !== 0) {
                this._data.style = value;
            }
            return this._data.style;
        },
        weight:function(value) {
            if (arguments.length !== 0) {
                this._data.weight = value;
            }
            return this._data.weight;
        },
        lineHeight:function(value) {
            if (arguments.length !== 0) {
                this._data.lineHeight = value;
            }
            return this._data.lineHeight;
        },
        family:function(value) {
            return this.properties.family(value);
        },
        bold:function(/*Boolean*/value){
            return this.properties.bold(value);
        }
    });
})();